package com.xiebiao.springboot3.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * <pre>
 *     https://docs.spring.io/spring-framework/reference/core/aop/ataspectj/pointcuts.html
 *     https://docs.spring.io/spring-framework/reference/core/aop-api.html
 *  </pre>
 *
 * @Description: XXX
 * @Author: Bill Xie
 * @Create: 2025/6/17 16:30
 **/
@Aspect
@Component
public class HelloServiceAspect {
    public HelloServiceAspect() {

    }

    /**
     * <pre>
     *     execution规则：
     *     execution(modifiers-pattern?
     * 			ret-type-pattern
     * 			declaring-type-pattern?name-pattern(param-pattern)
     * 			throws-pattern?)
     * 	 这里有详细内容：https://zhuanlan.zhihu.com/p/63001123
     * </pre>
     *
     * @param joinPoint
     */
    @Before("execution(* com.xiebiao.springboot3.service.HelloService.sayHello(..))")
    public void before() {

        System.out.println("aop before: com.example.service.HelloService.sayHello()");
    }
}
